//导入请求工具
import request from '@/utlis/request.js'

//导入pinia获取令牌
// import  { useTokenStore } from '@/stores/token.js'


//文章分类列表
export const articleCategoryListService= ()=>{
    // const tokenStore = useTokenStore()
    // return request.get('/category',{ headers: { 'Authorization': tokenStore.token } })
    //在请求拦截器里添加了令牌了，这里不需要加了
    return request.get('/category')
}


//添加文章分类
export const articleCategoryAddService = (categoryModel) => {
    return request.post('/category', categoryModel)
}

//修改分类
export const articleCategoryUpdateService = (categoryModel)=>{
    return request.put('/category',categoryModel)
}

//删除分类
export const articleCategoryDeleteService = (id) => {
    return request.delete('/category?id='+id)
}

//文章列表查询
// querystring是可以将url请求地址后的参数转化为对象，也可以把对象转化为url后的参数
export const articleListService = (params) => {
    return request.get('/article', { params: params })
}

//添加文章
export const articleAddService = (articleModel)=>{
    return request.post('/article',articleModel)
}

//更新文章
export const articleUpDataService = (articleModel) =>{
    return request.put('/article',articleModel)
}

///删除文章
export const articleDeleteService = (id)=>{
    return request.delete('/article?id='+id)

}
//查询单个文章
export const articleDetailService = (id)=>{
    return request.get('/article/detail?id=' + id)
}